/**
 * Created by Fesine on 2017/5/5.
 */

function sameSign(a,b) {
    return (a ^b ) >=0
    
}

function vector(a,b) {
    return{
        x:a.x-b.x,
        y:a.y-b.y
    }

}

function vectorProduct(v1,v2) {
    return v1.x*v2.y - v1.y*v2.x
}

function isPointIsTrangle(p,a,b,c) {
    var pa = vector(p,a);
    var pb = vector(p,b);
    var pc = vector(p,c);

    var t1 = vectorProduct(pa, pb);
    var t2 = vectorProduct(pb, pc);
    var t3 = vectorProduct(pc, pa);

    return sameSign(t1, t2) && sameSign(t2, t3);

}

function needDelay(elem,leftCorner,currMousePos) {
    var offset = elem.offset();
    var topLeft = {
        x:offset.left,
        y:offset.top
    };
    var bottomLeft ={
        x:offset.left,
        y:offset.top+elem.height()
    };
    return isPointIsTrangle(currMousePos, leftCorner, topLeft, bottomLeft);
}